<template><!---->
	<div id="test">
    <!--<title-top :fnlist="initObj.Fnlist"></title-top>-->
    <table-body :options="initObj" :hidePage="true"></table-body>
  </div>
</template>
<script>
//	import Cookies from 'js-cookie'
  import {teamScoreRank} from '@/api/compitionStatic'
  import tableBody from './tableListComponent'
	export default {
    name: 'scenes',
    props:['sceneId','poll','hlConfig'],
	data(){
    const a = function(val){
      this.selName = val;
      this.getRankingStatic();
    }.bind(this);
    const d = function(val){
      this.getRankingStatic(null,null,val)
    }.bind(this);
	  	return {
	  	  initObj:{
            Button:[
            ],
            Input:[
//            {
//            placeholder:'请输入团队名称',
//              fnName:a,
//            }
            ],
            Select:[
              // {
              //   optionsValue:
              //   [
              //     {
              //       id:1,
              //       name:'prj1'
              //     },
              //     {
              //       id:2,
              //       name:'prj2'
              //     }
              //   ]
              // }
            ],
            DatePicker:{
              isShow:false,
              fnName:d,
            },
            Page:{
              total:0,
              currentPage:1,
              pageSize:10
            },
            Table:{
              listCol:[
                {
                  title:'排行',
//                type: 'index',
                  align: 'center',
                  key:'rank',
//                width:60,
                  placement:'top-right',
                  order:2,
                  render:(h,params) => {
		            	let ele;
		            	if(params.row._index < 3){
		            		ele = h('img',{
		            			attrs:{
		            				src:require(`../../../../assets/scene/top${params.row._index+1}.png`)
		            			},
		            			style:{
		            				display:'inline-block',
//		            				width:'20px',
		            				verticalAlign: 'text-bottom',
    								marginLeft: '20px'
		            			}
		            		})
		            	}else{
		            		ele = h('span',params.row._index +1)
		            	}
		            	let index = params.row._index+1;
		            	let color;
		            	if(index == 1){
		            		color = '#f34938';
		            	}else if(index == 2){
		            		color = '#eb8205';
		            	}else if(index == 3){
		            		color = '#27b666';
		            	}else{
		            		color = '#000'
		            	}
		            	return h('span',[
		            		h('span',{
		            			style:{
		            				color:color
		            			}
		            		},'排行'),
		            		ele
		            	]);
		            }
                },
                {
                  title:'势力方名称',
                  key:'partyName',
                  align:'center',
                  ellipsis:true,
                  tooltip:true,
                  placement:'top-left',
                  order:1,
                  width: 240
                },
//              {
//                title:'排名',
//                key:'rank',
//                align:'center',
//                ellipsis:true,
//                tooltip:true,
//              },
                {
                  title:'总分',
                  key:'totalScore',
                  align:'center',
                  ellipsis:true,
                  tooltip:true,
                  width:80
                },
                {
                  title:'基础分',
                  key:'basicScore',
                  align:'center',
                  ellipsis:true,
                  tooltip:true,
                  width:80
                },
                 {
                  title:'攻击得分',
                  key:'attackScore',
                  align:'center',
                  tooltip:true,
                  width:80,
                  render:(h,params)=>{
                    return h('span', params.row.partyName=='蓝方'?'无':params.row.attackScore)
                  }
                },
                {
                  title:'防守失分',
                  key:'defendScore',
                  align:'center',
                  tooltip:true,
                  width:80,
                  render:(h,params)=>{
                    return h('span', params.row.partyName=='红方'?'无':params.row.defendScore)
                  }
                },
                {
                  title:'异常失分',
                  key:'expLoseScore',
                  align:'center',
                  ellipsis:true,
                  tooltip:true,
                  width:80,
                  render:(h,params)=>{
                    return h('span', params.row.partyName=='红方'?'无':params.row.expLoseScore)
                  }
                },
                {
                  title:'加减分',
                  key:'totalAddScore',
                  align:'center',
                  ellipsis:true,
                  tooltip:true,
                  width:80
                },
                // {
                //   title:'防守得分',
                //   key:'defendScore',
                //   align:'center',
                //   tooltip:true,
                //   width:80
                // },
//              {
//                title:'异常失分',
//                key:'exceptLostScore',
//                align:'center',
//                ellipsis:true,
//                tooltip:true,
//                render:(h,params)=>{
//                  return h('span', params.row.exceptLostScore||0)
//                }
//              },
//              {
//                title:'攻击总次数',
//                key:'totalCount',
//                align:'center',
//                ellipsis:true,
//                tooltip:true,
//              },
//              {
//                title:'攻击成功次数',
//                key:'attackCount',
//                align:'center',
//                ellipsis:true,
//                tooltip:true,
//                render:(h,params)=>{
//                  return h('span', params.row.attackCount||0)
//                }
//              },
//              {
//                title:'防守失败次数',
//                key:'defenseFailedCount',
//                align:'center',
//                ellipsis:true,
//                render:(h,params)=>{
//                  return h('span', params.row.defenseFailedCount||0)
//                }
//              }
              ],
              listData:[]
            },
            Fnlist:'getRankingStatic',
        },
//      sencenId:'',
        selName:'',
        timeout:{}
      }
	},
    components:{
//    'title-top':titleTop,
      'table-body':tableBody,
    },
    watch:{
    	
    },
    created(){
      //this.getRankingStatic();
    },
    beforeDestroy(){
		clearTimeout(this.timeout)
	},
	mounted(){
    	this.getRankingStatic();
      if(this.hlConfig!=1){
        this.initObj.Table.listCol.splice(3,5,
          {
            title:'攻击得分',
            key:'attackScore',
            align:'center',
            ellipsis:true,
            tooltip:true,
            width:80
          },
          {
            title:'异常得分',
            key:'exceptScore',
            align:'center',
            ellipsis:true,
            tooltip:true,
            width:80
          },
          {
            title:'防守得分',
            key:'defendScore',
            align:'center',
            ellipsis:true,
            tooltip:true,
            width:80
          },
        )
      }
	},
  methods:{
    getRankingStatic(page,pageSize,querytime){
      let _this = this;
      let pages = page || 1;
      this.$set(this.initObj.Page, 'currentPage', pages)
      let rows = pageSize||_this.PZ|| 10;
      let id = '';
      let params={
        pageIndex : pages,
        pageSize : rows
      };
      if(this.selName){
        params.teamName =  this.selName;
      }
      //if(querytime){
        //params.createtime = querytime[0];
        //params.lastupdatetime = querytime[1];
        //console.log(querytime)
      //}
      if(_this.$route.query.id){
        teamScoreRank(this.$route.query.id,params).then(data=>{
          if(data.code==1){
            _this.initObj.Table.listData = data.data.items;
            _this.initObj.Page.total = data.data.items.length;
            if(this.poll){ //如果需要轮询
            	clearTimeout(this.timeout)
            	this.timeout = setTimeout(() => {
            		this.getRankingStatic(page, pageSize);
            	},3000)
            }
          }
        })
      }
    },
    saveInfo(val){
      console.log('this is test');
      console.log(val);
    }
    },
}
</script>

<style>
  .drillsTable .ivu-poptip-body {
    text-align: left!important;
  }
  .scenesHeader{
    margin-bottom: 16px;
  }
  .drillTables{
    min-height: 300px;
  }
  .drillsTable.ivu-table-wrapper{
    overflow: inherit;
  }
</style>
<style scoped>
  .Titles{
    background: #eeeeee;
    margin: 16px auto;
    padding: 10px 0;
  }
  .targetHeader{
    padding: 10px;
    margin-bottom: 10px;
  }
</style>
